{load header}
<!--/H-->
    <!-- 内容区 -->
    <div id="main-content">
        <div id="top-alert" class="fixed alert alert-error" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content">这是内容</div>
        </div>
        <div id="main" class="main">
            
            <!-- nav -->
                        <!-- nav -->
            

            
	<div class="main-title">
        <h2>修改消息推送</h2>
    </div>
    <div class="cf">
	</div>
	    
    <div class="data-table">
        <div class="data-table table-striped">
            <form id='form' method="post" class="form-horizontal">
			<!-----table----->
                        <table class="table table-hover" style="width: 30%;">
				<thead>
				<tr>
					<th width='28%'>选项名称</th>
					<th width='72%'>选项值</th>
				</tr>
				</thead>
				<tbody>
                                    <tr style="height: 40px;">
                                                <td><span style="color:red;">*&nbsp;</span>消息类型：</td>
                                                <td>
                                                    <select id="type" name="type" style="width:150px;">
                                                        <option value="0">消息类型</option>
							<option value="2" {if $item['type'] == 2}selected="true"{/if}>活动通知</option>
                                                        <option value="4" {if $item['type'] == 4}selected="true"{/if}>公告通知</option>
                                                        <option value="6" {if $item['type'] ==6}selected="true"{/if}>贷款平台通知</option>
                                                    </select>
                                                </td>
                                    </tr>
                                    <tr style="height: 40px;">
                                        <td><span style="color:red;">*&nbsp;</span>消息标题：</td>
                                        <td>
                                            <input type="text" id="title" name="title" class="text input-large" value="{$item['title']}" style="width: 300px;" placeholder="在此输入">
                                        </td>
                                    </tr>
                                    <tr style="height: 40px;">
                                        <td><span style="color:red;">*&nbsp;</span>消息内容：</td>
                                        <td>
                                            <input type="text" id="content" name="content" class="text input-large" value="{$item['content']}" style="width: 300px;"  placeholder="在此输入">
                                        </td>
                                    </tr>
                                    <tr style="height: 40px;">
                                            <td><span style="color:red;">*&nbsp;</span>消息ID：</td>
                                            <td>
                                                <input type="text" id="target_id" name="target_id" class="text input-large" value="{$item['target_id']}" style="width: 80px;" placeholder="在此输入">
                                            </td>
                                    </tr>
                                    <tr style="height: 40px;">
                                            <td><span style="color:red;">*&nbsp;</span>推送平台(APP)：</td>
                                            <td>
                                                <label class="radio"><input {if $item['target_app']== "tan66"}checked{/if} type="radio" name="targetapp" class="targetapp" value="tan66" />弹溜溜</label>
                                                <label class="radio"><input {if $item['target_app']== "liuliuqianbao"}checked{/if} type="radio" name="targetapp"  class="targetapp" value="liuliuqianbao" />溜溜钱包</label>
                                            </td>
                                    </tr>
                                    <tr style="height: 40px;">
                                            <td><span style="color:red;">*&nbsp;</span>目标群体：</td>
                                            <td>
                                                <label class="radio"><input {if !$item['user_ids']}checked{/if} type="radio" name="aaa" class="userids" value="1" />全部用户</label>
                                                <label class="radio"><input {if $item['user_ids']}checked{/if} type="radio" name="aaa"  class="userids" value="0" />指定用户</label>
                                                <div id="box" style="display: none;"><input type="text" id="user_ids" name="user_ids" class="text input-large" value="{$item['user_ids']}" style="width: 300px;" placeholder="多个用户id用英文','隔开"></div>
                                            </td>
                                    </tr>
				</tbody>
			</table>
                        <br/>
                        <span style="color:red;margin-left: 10px;">PS：带*为必填项</span>
                        <br/>
                        <div class="form-item" style="margin-top: 10px;">
                        <input type='hidden' id="user_type" value="{if $item['user_ids']}0{else}1{/if}"/>
                        <input type='hidden' id="sms_id" value="{$item['id']}"/>
                        <a  href="javascript:void(0);" class="btn submit-btn" data-type="submit_yes" target-form="form-horizontal" style="padding-left:30px;padding-right:30px;">修改并重新推送</a>
                        <a href="javascript:void(0);" class="btn submit-btn" data-type="submit_no"  target-form="form-horizontal">只修改不推送</a>
                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                        </div>
            </form>
			<!-----/table----->
			<!-- 分页 -->
		</div>
    </div>
	
	
			</div>
	</div>
<script type="text/javascript">
    
$(function(){
    $(".userids").click(function(){
        var _val = $(this).val();
        if(_val == 1){//全体用户
            $("#box").hide();
            $("#user_ids").val("");
            $("#user_type").val(1);
        }else{//指定用户
            $("#box").show();
            $("#user_type").val(0)
        }
    });
    $(".submit-btn").click(function(){
        var that = this;
        var _act_type = $.trim($(this).attr("data-type")) == "submit_yes" ? 1 : 0;
         var _target_app = $('input:radio[name="targetapp"]:checked').val();
        $.ajax({
            url:"{eval echo site_url('pushsms/edit')}",async: false,dataType:"json",type:"post",data:{id:$("#sms_id").val(),user_type:$("#user_type").val(),title:$("#title").val(),content:$("#content").val(),type:$("#type").val(),target_id:$("#target_id").val(),target_app:_target_app,user_ids:$("#user_ids").val(),act_type:_act_type},
            success:function(data){
		if (data.status==1) {
                    if (data.url) {
                        updateAlert(data.info + ' 页面即将自动跳转~','alert-success');
                    }else{
                        updateAlert(data.info ,'alert-success');
                    }
                    setTimeout(function(){
                        if (data.url) {
                            location.href=data.url;
                        }else if( $(that).hasClass('no-refresh')){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('disabled').prop('disabled',false);
                        }else{
                            location.reload();
                        }
                    },1500);
                }else{
                    updateAlert(data.info);
                    setTimeout(function(){
                        if (data.url) {
                            location.href=data.url;
                        }else{
                            $('#top-alert').find('button').click();
                            $(that).removeClass('disabled').prop('disabled',false);
                        }
                    },1500);
                }
            }
        });
    });
});	
</script>
<!--F-->{load footer}